package org.taru.ems.common.common;


import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * 封装消息体,统一返回标准
 */
@Data
@AllArgsConstructor
public class CommonResult<T> {
    private Integer  status;
    private String message;
    private T   data;


    /**
     * 成功
     * @param message
     * @param data
     * @return
     */
    public  static  CommonResult OK(String message,Object data){
        return new CommonResult(200,message,data);
    }
    public  static  CommonResult OK(String message){
        return new CommonResult(200,message,null);
    }

    /**
     * 失败
     * @param message
     * @return
     */
    public  static  CommonResult ERR(String message){
        return new CommonResult(500,message,null);
    }
    public  static  CommonResult ERR(Integer  status ,String message){
        return new CommonResult(status,message,null);
    }
    public  static  CommonResult ERR(Integer  status ,String message,Object data){
        return new CommonResult(status,message,data);
    }


}
